package com.systemservice.controller;

import annotation.DisableBaseResponse;
import com.systemservice.service.LoginService;
import com.systemservice.service.RoleService;
import com.systemservice.service.UserInfoService;
import generator.domain.Login;
import generator.support.ResponseResult;
import generator.vo.LoUsRo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/sys/login")
@Slf4j
@CrossOrigin
public class loginController {
    @Autowired
    UserInfoService userInfoService;

    @Autowired
    RoleService roleService;

    @Autowired
    LoginService loginService;

    /**
     * 获取所有用户信息
     */
    @GetMapping("/getAll")
    public List<Map<String, Object>> getAllLogin(){
        log.info("LoginController -> getAllLogin");
        return loginService.getAllLogin();
    }

    /**
     * 模糊查询用户信息
     */
    @PostMapping("/like")
    public List<Map<String, Object>> likeLogin(@RequestBody Login login){
        log.info("LoginController -> likeLogin");
        return loginService.likeLogin(login);
    }

    /**
     * 添加账户
     */
    @PostMapping("/add")
    @DisableBaseResponse
    public ResponseResult<Object> addLogin(@RequestBody LoUsRo loUsRo){
        log.info("LoginController -> addLogin");
        return loginService.addNewLogin(loUsRo);
    }

    /**
     * 修改账户信息
     */
    @PostMapping("/edit")
    @DisableBaseResponse
    public ResponseResult<Object> editLogin(@RequestBody LoUsRo loUsRo){
        log.info("LoginController -> editLogin");
        return loginService.editLogin(loUsRo);
    }
}
